/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aptech.bluepumpkin;

import java.io.Serializable;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Trong Nguyen
 */
@Entity
@Table(name = "Winner")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Winner.findAll", query = "SELECT w FROM Winner w"),
    @NamedQuery(name = "Winner.findById", query = "SELECT w FROM Winner w WHERE w.id = :id")})
public class Winner implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
   @GeneratedValue(strategy = GenerationType.IDENTITY) 
    @Column(name = "id")
    private Integer id;
    @JoinColumn(name = "registration", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Registration registration;
    @JoinColumn(name = "prize", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Prize prize;

    public Winner() {
    }

    public Winner(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Registration getRegistration() {
        return registration;
    }

    public void setRegistration(Registration registration) {
        this.registration = registration;
    }

    public Prize getPrize() {
        return prize;
    }

    public void setPrize(Prize prize) {
        this.prize = prize;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Winner)) {
            return false;
        }
        Winner other = (Winner) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.aptech.bluepumpkin.Winner[ id=" + id + " ]";
    }
    
}
